package com.tairanchina.md.meeting.service.impl;

import com.tairanchina.md.meeting.dao.YearMeetingTreeMapperExt;
import com.tairanchina.md.meeting.entity.YearMeetingTree;
import com.tairanchina.md.meeting.entity.YearMeetingTreeExample;
import com.tairanchina.md.meeting.service.YearMeetingTreeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by lxliuxuan on 2016/12/28.
 */
@Transactional
@Service
public class YearMeetingTreeServiceImpl implements YearMeetingTreeService{

    @Resource
    private YearMeetingTreeMapperExt treeDao;
    @Override
    public YearMeetingTree findTree() {

        List<YearMeetingTree> yearMeetingTrees = treeDao.selectByExample(null);
        if(yearMeetingTrees != null && !yearMeetingTrees.isEmpty()){
            return yearMeetingTrees.get(0);
        }
        return null;
    }

    @Override
    public void updateTree(YearMeetingTree tree) {
        YearMeetingTreeExample example = new YearMeetingTreeExample();
        YearMeetingTreeExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(tree.getId());
        treeDao.updateByExampleSelective(tree,example);

    }
}
